package com.zyh.B;

public class Test2 {
    public static void main(String[] args) {
        /*
        定义一个方法，求数组的平均值
         */
        double[] arr={3.14,3.15,3.16};
        double avg = getAvg(arr);
        System.out.println("avg = " + avg);
    }
    public static double getAvg(double[] arr){
        double sum=0.0;
        for (int i = 0; i < arr.length; i++) {
            sum=sum+arr[i];
        }
        return sum/arr.length;
    }
}
